package com.zr.controller;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.zr.service.ValidateService;
/**
 * 用户检验用户名是否存在的controller
 * @author Administrator
 *
 */
public class ValidataUnameController extends HttpServlet{
	ValidateService vs=new ValidateService();
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doPost(req, resp);
	}
	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		// TODO Auto-generated method stub
			String  uname = req.getParameter("uname");
		   boolean  flag = vs.validataUname(uname);
		   //获取回复的那只笔
		   resp.setCharacterEncoding("utf8");
		   PrintWriter pw = resp.getWriter();
		   if(flag){
			   pw.write("有该用户,可以登陆");
		   }else{
			   pw.write("对不起,无此用户,你需要注册");
		   }
		}
	}
